package com.ssy.lingxi.platform.template.service.controller.mobile;

import com.ssy.lingxi.common.controller.BaseController;
import com.ssy.lingxi.common.model.vo.PageVO;
import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.platform.template.service.entity.door.MemberShop;
import com.ssy.lingxi.platform.template.service.model.dto.common.CollectDTO;
import com.ssy.lingxi.platform.template.service.model.dto.common.IdDTO;
import com.ssy.lingxi.platform.template.service.model.dto.common.MemberIdAndRoleIdDTO;
import com.ssy.lingxi.platform.template.service.model.dto.mobile.MemberShopInGoodsListMobileDTO;
import com.ssy.lingxi.platform.template.service.model.dto.mobile.MemberShopMainMobileDTO;
import com.ssy.lingxi.platform.template.service.model.qo.MemberShopMobileQO;
import com.ssy.lingxi.platform.template.service.model.vo.mobile.MemberShopInGoodsListMobileVO;
import com.ssy.lingxi.platform.template.service.model.vo.mobile.MemberShopListMobileVO;
import com.ssy.lingxi.platform.template.service.model.vo.mobile.MemberShopMainMobileVO;
import com.ssy.lingxi.platform.template.service.service.mobile.MemberShopMobileService;
import com.ssy.lingxi.report.api.vo.response.PopularShopVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;
import java.util.Map;

/**
 * @menu mobile - 会员店铺门户
 * @author fhj
 * @version 2.0.0
 * @date 2020/12/11
 */
@Api(tags = "mobile - 会员店铺门户")
@RestController
@RequestMapping("/template/mobile/memberShopMobile")
public class MemberShopMobileController extends BaseController {

    @Resource
    private MemberShopMobileService memberShopMobileService;

    @ApiOperation(value = "会员店铺主页")
    @GetMapping("/memberShopMain")
    public Wrapper<MemberShopMainMobileVO> memberShopMain(@Valid MemberShopMainMobileDTO dto) {
        return memberShopMobileService.memberShopMain(dto, isLogin() ? getSysUser() : null);
    }

    @ApiOperation(value = "店铺门户列表")
    @GetMapping("/memberShopList")
    public Wrapper<PageData<MemberShopListMobileVO>> memberShopList(@Valid MemberShopMobileQO qo) {
        return memberShopMobileService.memberShopList(qo, getHeadersShopId());
    }

    @ApiOperation(value = "人气店铺和最新上架三个商品")
    @GetMapping("/popularStore")
    public Wrapper<List<MemberShopListMobileVO>> popularStore(@RequestParam(value = "provinceCode",defaultValue = "0") String provinceCode,@RequestParam(value = "cityCode",defaultValue = "0") String cityCode) {
        return memberShopMobileService.popularStore(getHeadersShopId(),provinceCode,cityCode);
    }

    @ApiOperation(value = "人气店铺信息")
    @GetMapping("/popularStoreMsg")
    public Wrapper<List<PopularShopVO>> popularStoreMsg() {
        return memberShopMobileService.popularStoreMsg(getHeadersShopId());
    }

    @ApiOperation(value = "店铺门户包含商品列表")
    @PostMapping("/memberShopInGoodsList")
    public Wrapper<List<MemberShopInGoodsListMobileVO>> memberShopInGoodsList(@RequestBody @Valid MemberShopInGoodsListMobileDTO dto) {
        return memberShopMobileService.memberShopInGoodsList(dto);
    }

    @ApiOperation(value = "根据会员ID和角色ID获取店铺")
    @GetMapping("/findByMemberIdAndRoleId")
    public Wrapper<MemberShopMainMobileVO> findByMemberIdAndRoleId(@Valid MemberIdAndRoleIdDTO dto) {
        return memberShopMobileService.findByMemberIdAndRoleId(dto, isLogin() ? getSysUser() : null);
    }

    @ApiOperation(value = "根据店铺ID获取店铺")
    @GetMapping("/findById")
    public Wrapper<MemberShop> findById(@Valid IdDTO dto) {
        return memberShopMobileService.findById(dto);
    }

    @ApiOperation(value = "收藏列表")
    @GetMapping(value = "/collectList")
    public Wrapper<PageData<MemberShop>> collectList(PageVO dto) {
        return memberShopMobileService.collectList(dto, getSysUser());
    }

    @ApiOperation(value = "收藏/取消收藏")
    @PostMapping(value = "/collect")
    public Wrapper<Void> collect(@RequestBody @Validated CollectDTO dto) {
        return memberShopMobileService.collect(dto, getSysUser());
    }

    @ApiOperation(value = "新入店铺")
    @GetMapping("/newAddStore")
    public Wrapper<PageData<MemberShop>> newAddStore(PageVO dto) {
        return memberShopMobileService.newAddStore(dto);
    }
}
